import { PureComponent } from "react"
import { isNull, filterTemplate } from "../../utils/helper"
import MAction from "../MAction/MAction"

interface Props {
	list?: {
		[k: string]: any
	}[],
	formData: object,
	template?: string,
	event_key?: string
}
interface State {

}
export default class MListViewNormal extends PureComponent<Props, State>{
	public state: State = {

	}
	public render() {
		let { list, formData, template } = this.props;
		return (
			<div>
				{
					list.map((item, key) => {
						return <div key={key} dangerouslySetInnerHTML={{ __html: filterTemplate(template, item) }} onClick={() => {
							let { event_key } = item;
							MAction({ ...this.props, formData: { ...formData, ...item } }, event_key || this.props.event_key)
						}}>
						</div>
					})
				}
			</div>
		)
	}
}